

package edu.gatech.startrader.unit_tests;

import edu.gatech.startrader.trade.Cargo;
import edu.gatech.startrader.trade.TradeGood;
import junit.framework.*;
import edu.gatech.startrader.ship.*;
public class Tests extends TestCase { 
   
	public Tests(String name)
   { 
      super(name);
   }
   
	//Stefan's Test for the addCargo method
	   public void testAddCargo() {
		   //creates a new cargo object of size 12
		   Cargo cargo = new Cargo(12);
		   
		   //make sure that there are 12 cargo holds
		   assertEquals(12, cargo.getCargoHolds());
		   
		   //add in cargo (12 holds * 5 cargo per hold)
		   cargo.addCargo(TradeGood.WATER, 60);
		   
		   //check the current amount of cargo space
		   assertEquals(0, cargo.checkRemainingCargoSpace());
		   
		   //try to insert more cargo
		   IllegalArgumentException error = null;
		   try
		   {
		       cargo.addCargo(TradeGood.WATER, 1);
		   }
		   catch(IllegalArgumentException waterError)
		   {
			   error = waterError;
		   }
		   
		   //make sure that the error is caught
		   assertNotNull(error);
		   
		   //remove 20 water
		   cargo.removeCargo(TradeGood.WATER, 20);
		   
		   //check that there is 20 free cargo space
		   assertEquals(20, cargo.checkRemainingCargoSpace());
	   }
   
   //Jae's Test for the checkRemainingCargoSpace method
   public void testCheckRemainingCargoSpace() {
	   //after cargo added
	   Cargo cargo = new Cargo(10);
	   int amount = cargo.getCargoHolds() * 5; //multiply by 5 because there are 5 items in each CargoSpace/CargoHold
	   cargo.addCargo(TradeGood.WATER, 2);
	   assertEquals(amount - 2, cargo.checkRemainingCargoSpace());
	   
	   //after cargo removed
	   cargo.removeCargo(TradeGood.WATER, 2);
	   assertEquals(amount, cargo.checkRemainingCargoSpace());
   }
   
    //Zohra's Test for the refuel method
   public void testRefuel(){
	   //create a new ship
	   Ship ship = new Ship(ShipType.FLEA);
	   
	   //check that the ship's max fuel is equal to the amount of fuel in the tank
	   assertEquals(ship.getMaxFuel(), ship.getFuel());
   }
   //Chris's Test for the getCargoHolds method
   public void testGetShipType()
   {	   
	   
	   Ship ship = new Ship(ShipType.GNAT);	   
	   assertEquals(ShipType.GNAT, ship.getType());	   
   }
}

